package com.youlu.campus.service.ca;

import com.youlu.campus.entity.CaMaterialConfig;
import com.youlu.campus.entity.VO.req.CaMaterialConfigQueryVO;
import org.springframework.data.domain.Page;

import java.util.List;

public interface CaMaterialConfigService {

    Page<CaMaterialConfig> list(CaMaterialConfigQueryVO req);

    void create(CaMaterialConfig config);

    boolean update(CaMaterialConfig config);

    CaMaterialConfig findOne(String id);

    boolean delete(String id);

    /**
     * 拷贝材质
     * @param copyActivityId
     * @param newActivityId
     */
    void doCopyCaMaterialConfig(String copyActivityId,String activityName,String newActivityId);

    /**
     * 设置已售数量
     * @param id
     * @param stockNum
     * @return
     */
    void setSoldCount(String id,Integer stockNum);

    /**
     * 获取已售数量
     * @param id
     * @return
     */
    Integer getSoldCount(String id);

    /**
     * 是否已超卖，库存小于了已售数量
     * @param id
     * @return true 已超卖 false 未超卖
     */
    Boolean overbought(String id);

    /**
     * 获取已售数量
     * @param caMaterialIdList
     * @return
     */
    Integer getBatchSoldCount(List<String> caMaterialIdList);


    List<CaMaterialConfig> findByCaMaterialIdList(List<String> caMaterialIdList);


    /**
     * 是否已超卖，库存小于了已售数量
     * @param id
     * @return true 已超卖 false 未超卖
     */
    Boolean overboughtByIdAndNum(String id,Integer num);

    Integer getStockById(String id);
}
